<?php
class CategoryControl extends CommonControl {
	public function index(){ 
		$cate=new CategoryModel();
		$cateDate=$cate->fetchAll();
		$cateDate=pidsort($cateDate);
		require_once('View/Admin/Category/catelist.php');
	}
	public function add(){
		$this->view->display('add.html');
	}
	public function addson(){
		require_once('View/Admin/Category/addson.php');
	}
	
	public function addck(){
		$cate=new CategoryModel();
		$num=$cate->insert($_POST);
		if($num>0){
			$this->success('/index.php/Admin/Category/index');
		}else{
			$this->error('/index.php/Admin/Category/index');
		}
	}
	public function update(){
		$id=$_GET['id'];
		$cate=new CategoryModel();
		$cateDate=$cate->fetchRow($id);
		require_once('View/Admin/Category/update.php');
	}
	public function updateck(){
		$cate=new CategoryModel();
		$num=$cate->update($_POST);
		if($num>0){
			$this->success('/index.php/Admin/Category/index');
		}else{
			$this->error('/index.php/Admin/Category/index');
		}
	}
	public function delete(){
		$id=$_GET['id'];
		$cate=new CategoryModel();
		$res=$cate->catedel($id);
		if($res){
			$this->success('/index.php/Admin/Category/index','删除'.$res.'条分类');
		}else{
			$this->error('/index.php/Admin/Category/index');
		}
	}
}
?>